package com.zjk.file.controller;

import com.zjk.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @author: gfk
 * @create: 2022/10/17
 * @Description:
 * @FileName: NativeUploadController
 * @History:
 * @自定义内容： 本地上传
 */
@RestController
@RequestMapping("/file/upload")
public class NativeUploadController {

    @PostMapping("/native")
    public Result nativeUpload(@RequestParam("file") MultipartFile file) throws IOException {

        String contentType = file.getContentType();
        String originalFilename = file.getOriginalFilename();
        File file1 = new File("C:\\Users\\l\\Pictures\\Camera Roll",originalFilename);
        file.transferTo(file1);

        return Result.SUCCESS();

    }
}
